# BigData course project
# Serial version of training algorithm for SOM
# Main module (classification algorithm)

import sys
from trainset import TrainSet
from som import SOM
from util import *

if len(sys.argv) != 10:
    log("Passed %d args\n", len(sys.argv))
    log("Usage: %s <dim> <ts_size> <ts_file> <size_x> <size_y> " +
        "<som_file_fin> <class_file> <debug> " + 
        "<show_progress>", sys.argv[0])
    sys.exit(1)

dim = int(sys.argv[1])
ts_size = int(sys.argv[2])
ts_file = sys.argv[3]
size_x = int(sys.argv[4])
size_y = int(sys.argv[5])
som_file_fin = sys.argv[6]
class_file = sys.argv[7]
debug = int(sys.argv[8])
show_progress = int(sys.argv[9])

ts = TrainSet(dim, ts_size, ts_file)
som = SOM(ts, 1, size_x, size_y, 0, 0, False, som_file_fin)
log("classifying trainset with som ...\n");
som.classify(class_file, show_progress)
log("classification done.\n");
